//
//  NSObject+ToolObject.m
//  TimeMemory
//
//  Created by 冼雪雪 on 14/11/16.
//  Copyright (c) 2014年 XXX. All rights reserved.
//

#import "NSObject+ToolObject.h"

@implementation NSObject (ToolObject)

- (BOOL)judgmentIsEmpty:(NSString *)Character
{
    if (Character.length>0&&![Character isEqual:@""]&&Character!=nil)
    {
        return YES;
    }
    return NO ;
}

//字符转换,'&lt'转换为'<','&gt'转换为'>'
-(NSString *)deWordConver:(NSString *)str
{
    NSString *first;
    
    first = [[str stringByReplacingOccurrencesOfString:@"&lt;" withString:@"<"] stringByReplacingOccurrencesOfString:@"&gt;" withString:@">"];
    first = [first stringByReplacingOccurrencesOfString:@"<RetData>" withString:@""];
    first = [first stringByReplacingOccurrencesOfString:@"</RetData>" withString:@""];
    
    return first;
}
- (BOOL)isalphanumericunderscore:(NSString *)string
{
    static NSString *tempStr = @"^[0-9a-zA-Z_]+$";
    BOOL isJudgment = [self isjudgment:tempStr string:string];
    return isJudgment;
}
- (BOOL)inbothChineseandEnglish:(NSString *)string
{
    static NSString *tempstring = @"[\u4e00-\u9fa5\\w]+";
    BOOL isjudgment =  [self isjudgment:tempstring string:string];
    return isjudgment;
}
- (BOOL)isjudgment:(NSString *)tempStr string:(NSString *)string
{
    NSRegularExpression *regularexpression = [[NSRegularExpression alloc]initWithPattern:tempStr options:NSRegularExpressionCaseInsensitive error:nil];
    if (regularexpression)
    {//对象进行匹配
        NSUInteger numberofMatch = [regularexpression numberOfMatchesInString:string options:NSMatchingReportProgress range:NSMakeRange(0, string.length)];
        if (numberofMatch==0)
        {
            return NO;
        }else
        {
            return YES;
        }
    }
    return NO;

}
@end
